package top.datacluster.basic.algorithm.leetcode.stack;

import java.util.Stack;

public class LeetCode1437 {
}


class MyQueue {

    private Stack<Integer> data = new Stack<>();

    private Stack<Integer> temp = new Stack<>();

    /** Initialize your data structure here. */
    public MyQueue() {

    }

    /** Push element x to the back of queue. */
    public void push(int x) {
        data.push(x);
    }

    /** Removes the element from in front of queue and returns that element. */
    public int pop() {
        if (!temp.isEmpty()){
            return temp.pop();
        }
        while (!data.isEmpty()){
            temp.push(data.pop());
        }
        return temp.pop();
    }

    /** Get the front element. */
    public int peek() {
        if (!temp.isEmpty()){
            return temp.peek();
        }
        while (!data.isEmpty()){
            temp.push(data.pop());
        }
        return temp.peek();
    }

    /** Returns whether the queue is empty. */
    public boolean empty() {
        return data.isEmpty() && temp.isEmpty();
    }
}